<!doctype html>
<html lang="en">
  <head>
    <title>表格组件</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
  </head>
  <body>
    <div id="app">
        <nav class="navbar navbar-expand-md  navbar-dark" style="background-color: #0991f3;">
            <a class="navbar-brand" href="#">林科大校医 🏥 </a>
            <div class="collapse navbar-collapse" id="collapsibleNavId">
                <!-- 在这个导航栏中定义每一个选项 -->
                <ul class="navbar-nav mr-auto mt-2 mt-lg-0">
                    <!-- 一个选项就是一个li标签 -->
                    <li class="nav-item active ml-3">
                        <a class="nav-link" href="#">首页<span class="sr-only">(current)</span></a>
                    </li>
                    <li class="nav-item ml-3">
                        <a class="nav-link" href="#">文件</a>
                    </li>
                    <!-- 有下拉选项的li标签 -->
                    <li class="nav-item dropdown ml-3">
                        <a class="nav-link dropdown-toggle" href="#" id="dropdownId" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">编辑</a>
                    <!-- 下拉选项的值 -->
                        <div class="dropdown-menu" aria-labelledby="dropdownId">
                            <a class="dropdown-item" href="#">撤销</a>
                            <a class="dropdown-item" href="#">恢复</a>
                            <a class="dropdown-item" href="#">剪切</a>
                            <a class="dropdown-item" href="#">复制</a>
                        </div>
                    </li>
                    <li class="nav-item dropdown ml-3">
                        <a class="nav-link dropdown-toggle" href="#" id="dropdownId" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">选择</a>
                    <!-- 下拉选项的值 -->
                        <div class="dropdown-menu" aria-labelledby="dropdownId">
                            <a class="dropdown-item" href="#">撤销</a>
                            <a class="dropdown-item" href="#">恢复</a>
                            <div class="dropdown-divider"></div>
                            <a class="dropdown-item" href="#">剪切</a>
                            <a class="dropdown-item" href="#">复制</a>
                        </div>
                    </li>
                </ul>
                <form class="form-inline my-2 my-lg-0">
                    <input class="form-control mr-sm-2" type="text" placeholder="Search">
                    <button class="btn btn-danger my-2 my-sm-0" type="submit">Search</button>
                </form>
            </div>
        </nav>
        <!-- 组件2：展板 b4-jum -->
        <div class="jumbotron jumbotron-fluid py-3">
            <div class="container">
                <!-- dispaly-1/5:表示字体大小 -->
                <h1 class="display-4">线上挂号系统</h1>
                <p class="lead">林科大校医</p>
            </div>
            <nav class="breadcrumb">
                <a class="breadcrumb-item" href="index.html">科室导航</a>
                <span class="breadcrumb-item active">{{doctor.name}}医生排班</span>
                <a class="breadcrumb-item" href="patient.html">就诊人管理</a>
                <a class="breadcrumb-item" href="reservationinfo.html">我的预约信息</a>
            </nav>
        </div>
        <!-- 核心部分 -->
        <div class="container">
            <h1 class="font-weight-light h2 mb-4">{{doctor.name}}医师的排班信息</h1>
            <!-- 表格显示 b4-table -->
            <table class="table table-bordered">
                <tbody>
                    <tr>
                        <td v-for="(schedul, index) in schedulArr" :key="index">
                            <p v-if="schedul.week==1" style="font-weight: 700;">星期天</p>
                            <p v-if="schedul.week==2" style="font-weight: 700;">星期一</p>
                            <p v-if="schedul.week==3" style="font-weight: 700;">星期二</p>
                            <p v-if="schedul.week==4" style="font-weight: 700;">星期三</p>
                            <p v-if="schedul.week==5" style="font-weight: 700;">星期四</p>
                            <p v-if="schedul.week==6" style="font-weight: 700;">星期五</p>
                            <p v-if="schedul.week==7" style="font-weight: 700;">星期六</p>
                            <hr>
                            <p class="badge badge-primary" style="font-size: 24px;">{{schedul.time}} </p> 
                            <p>{{schedul.clinic.title}} </p>
                            <p>{{schedul.clinic.fees}}元</p>
                            <p><a type="button" @click="appoint(schedul)" v-if="schedul.count<30 "  class="btn btn-outline-success">挂号 剩余号：{{30-schedul.count}}</a></p> 
                            <p><a type="button" v-if="schedul.count==30"   class="btn btn-outline-danger disabled">剩余号：{{30-schedul.count}}</a></p> 
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <!-- 页脚&网址地图 -->
        <div class="jumbotron jumbotron-fluid mb-0 mt-5 py-3">
            <div class="container">
                <p class="lead text-center">copyright 牛耳教育@2022</p>
            </div>
        </div>
    </div>  
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script> 
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
  </body>
</html>
<script>
     var url = `http://39.108.176.33:8080`;
    var vm = new Vue({
        el:"#app",
        data() {
            return {
                doctor:{
                    id:-1,
                    name:"请选择医生"
                },
                schedulArr:[],
                curTime:new Date().getFullYear+"-"+new Date().getMonth()+"-"+new Date().getDate(),
            }
        },
        mounted() {
            //获取医生
           this.doctor = JSON.parse(sessionStorage.getItem("doctor"));
           this.getScheduling(this.doctor.id);
        },
        methods: {
            //通过医生id找到排班信息
            getScheduling(id){
                axios.get(`${url}/api/scheduling/${id}`)
                .then((response)=> {
                    this.schedulArr = response.data;
                })
                .catch(function (error) {
                })
            },
            //挂号
            appoint(schedul){
                //将排班信息，跳转到下一页
                sessionStorage.setItem("schedul",JSON.stringify(schedul));
                location.href="reservatio.html"
            }
        },
    })
</script>